/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
  \file			session.h
  \date			Feb 2012
  \author		TNick

  \brief		Contains the definition for Session class


*//*


 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Please read COPYING and README files in root folder
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __SESSION_INC__
#define __SESSION_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

#include	<QList>
#include	<QChar>

#include	<txlist.h>


/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

namespace	ObjD	{

class	ObjDef;
class	Session;


/**
*	@brief a complete set of states
*/
class Session				{

	//
	//
	//
	//
	/*  DEFINITIONS    ----------------------------------------------------- */

#ifdef	OBJECTSLIB_TESTS
	friend void		Session_Tests	( int&, int& );
#endif

	/*  DEFINITIONS    ===================================================== */
	//
	//
	//
	//
	/*  DATA    ------------------------------------------------------------ */

protected:

	/**
	*	@brief	the list of predefined objects
	*/
	ObjDef *		p_predef;


	/**
	*	@brief	the tree of actual objects
	*/
	ObjDef *		p_tree;


	/**
	*	@brief	the list of names
	*/
	TxList			names_;


	/**
	*	@brief	the list of descriptions
	*/
	TxList			descr_;


	/*  DATA    ============================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */

public:


	/**
	*	@brief	constructor;
	*/
	Session			( void );


	/**
	*	@brief	destructor;
	*/
	virtual			~Session		( void );



	/**
	*	@brief	first predefined object in the chain
	*/
	inline ObjDef *		firstTemplate	( void )
	{ return p_predef; }


	/**
	*	@brief	first actual object in the chain
	*/
	inline ObjDef *		firstObject		( void )
	{ return p_tree; }


	/**
	*	@brief	the name at index i
	*/
	inline QChar *		name			( unsigned i )
	{
		if (i >= names_.count() ) return NULL;
		return names_.at( i );
	}


	/**
	*	@brief	number of names that are internally stored
	*/
	inline unsigned		nameCount		( void )
	{ return names_.count( ); }


	/**
	*	@brief	add a name to the internal list
	*
	*	It is assummed that the name was properly formatted (the reference
	*	count, the number of characters and ending NULL were placed properly)
	*/
	inline unsigned		addName			( QChar * p_targ )
	{ return names_.append( p_targ ); }


	/**
	*	@brief	add a name to the internal list
	*
	*	A new buffer will be allocated for it
	*/
	inline QChar *		addName			( QString & s_to_add, unsigned & idx )
	{ return names_.addUniq( s_to_add, idx ); }


	/**
	*	@brief	add a name to the internal list
	*
	*	A new buffer will be allocated for it
	*/
	inline QChar *		addName			( unsigned & idx, QString s_to_add )
	{ return names_.addUniq( s_to_add, idx ); }


	/**
	*	@brief	add a name to the internal list
	*
	*	A new buffer will be allocated for it
	*/
	inline QChar *		addName			( const char * s_to_add, unsigned & idx )
	{ return names_.addUniq( s_to_add, idx ); }




	/**
	*	@brief	the description at index i
	*/
	inline QChar *		description		( unsigned i )
	{
		if (i >= descr_.count() ) return NULL;
		return descr_.at( i );
	}


	/**
	*	@brief	number of descriptions that are internally stored
	*/
	inline unsigned		descrCount		( void )
	{ return descr_.count( ); }


	/**
	*	@brief	add a description to the internal list
	*
	*	It is assummed that the string was properly formatted (the reference
	*	count, the number of characters and ending NULL were placed properly)
	*/
	inline unsigned		addDescr			( QChar * p_targ )
	{ return descr_.append( p_targ ); }


	/**
	*	@brief	add a description to the internal list
	*
	*	A new buffer will be allocated for it
	*/
	inline QChar *		addDescr			( QString & s_to_add, unsigned & idx )
	{ return descr_.addUniq( s_to_add, idx ); }


	/**
	*	@brief	add a description to the internal list
	*
	*	A new buffer will be allocated for it
	*/
	inline QChar *		addDescr			( unsigned & idx, QString s_to_add )
	{ return descr_.addUniq( s_to_add, idx ); }


	/**
	*	@brief	add a description to the internal list
	*
	*	A new buffer will be allocated for it
	*/
	inline QChar *		addDescr			( const char * s_to_add, unsigned & idx )
	{ return descr_.addUniq( s_to_add, idx ); }


	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

};	/*	class Session	*/

/*  CLASS    =============================================================== */
//
//
//
//

#ifdef	OBJECTSLIB_TESTS
void				Session_Tests					(
		int & performed, int & succeded );
#endif

}	//	namespace	ObjD

#endif // __SESSION_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
